package com.shanpin.shebao.admin.module.material;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.shanpin.shebao.admin.db.AppDbRepository;
import com.shanpin.shebao.admin.module.material.model.MaterialResp;
import com.shanpin.shebao.model.material.constant.MaterialStatus;

@Repository
public class MaterialDao {

	@Autowired
	private AppDbRepository app;
	
	public List<MaterialResp> getMaterials(int f_id) {
		String sql = "SElECT * FROM t_sb_material WHERE f_id=? AND material_status=? "
					+" ORDER BY create_time desc ";
		return app.query(sql, MaterialResp.MAPPER, f_id, MaterialStatus.AVAIL.getNum());
	}
	
	public boolean delMaterial(int f_id, int id) {
		String sql = "UPDATE t_sb_material SET material_status=? WHERE f_id=? AND id=?";
		return app.update(sql, MaterialStatus.DELETE.getNum(), f_id, id);
	}
}
